


CC	:= gcc 
CFLAGS := -g -Wall -Werror $(LABDEFS)

TARGETS := test1 test2

# Make sure that 'all' is the first target
all: $(TARGETS)

clean:
	rm -rf core *.o *.out $(TARGETS)

realclean: clean
	rm -rf *~ *.bak


tags:
	etags *.c *.h

TURNIN := /lusr/bin/turnin
GRADER := matsuoka
LAB_NAME := handin-372-lab-T
handin: handin.tar
	echo "Turning in handin.tar containing the following files:"
	tar tf handin.tar
	$(TURNIN) --submit $(GRADER) $(LAB_NAME) handin.tar


handin.tar: clean
	tar cf handin.tar `find . -type f | grep -v '^\.*$$' | grep -v '/CVS/' | grep -v '/\.svn/' | grep -v '/\.git/' | grep -v 'lab[0-9].*\.tar\.gz' | grep -v '/\~/' | grep -v 'C.html' | grep -v '/\.tar/'` 





#
# Individual .c, .o files.
#
# To keep things simple and obvious in the makefile
# I list the dependencies explicitly. For large
# projects with more interesting dependencies, it
# is better to generate them automatically.	
#  See 
#
#        Recursive Make Considered Harmful
#        http://aegis.sourceforge.net/auug97.pdf
#
# for an explanation (as well as a very nice discussion
# about structuring Makefiles for larger projects.
#
# Explicit dependencies instead, to keep things simple:

sthread.o: sthread.h sthread.c
	gcc -c $(CFLAGS) -o $@ sthread.c

OBLBasic_Table.o: sthread.h OBLBasic_Table.c OBLBasic_Table.h
	gcc -c $(CFLAGS) -o $@ OBLBasic_Table.c

OBLFair_Table.o: sthread.h OBLFair_Table.c OBLFair_Table.h
	gcc -c $(CFLAGS) -o $@ OBLFair_Table.c

SimpleStats.o: sthread.h SimpleStats.c SimpleStats.h
	gcc -c $(CFLAGS) -o $@ SimpleStats.c

test1.o: test1.c OBLBasic_Table.h sthread.h SimpleStats.h
	gcc -c $(CFLAGS) -o $@ test1.c

test1: sthread.o OBLBasic_Table.o test1.o SimpleStats.o
	gcc $(CFLAGS) -lpthread -o $@ sthread.o OBLBasic_Table.o test1.o SimpleStats.o

test2.o: test2.c OBLFair_Table.h sthread.h SimpleStats.h
	gcc -c $(CFLAGS) -o $@ test2.c

test2: sthread.o OBLFair_Table.o test2.o SimpleStats.o
	gcc $(CFLAGS) -lpthread -o $@ sthread.o OBLFair_Table.o test2.o SimpleStats.o

